package cn.marinda.runnable;

import cn.marinda.MinecraftServerHelper;

import javax.swing.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimerTask;

/**
 * 时间runnable
 *
 * @author admin
 * @date 2022/07/08
 */
public class TimeRunnable extends TimerTask {
    private JFrame jFrame;
    private String text;
    public TimeRunnable(JFrame frame){
        this.jFrame = frame;
        this.text = jFrame.getTitle();
    }

    @Override
    public void run() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
        Date dt = new Date();
        String formatTime = simpleDateFormat.format(dt);
        jFrame.setTitle( text + "\t 当前时间：" + formatTime);

    }
}
